﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Myproject.DataCRM;

namespace Myproject.DataAccess.factory
{
    public class DBFactoryInstance : DBEntities
    {
        static readonly object lockobject = new object();
        static DBFactoryInstance dbInstance = null;

        DBFactoryInstance()
        {
             //dbInstance = new DBFactoryInstance();此处不用声明，因为在父类中的构造方法中，有实例化方法，如时再次实例化，反复实例化，内存溢出的情况发生。
        }

        public static DBFactoryInstance DbInstance
        {
            get { 
                    if(dbInstance==null)
                    {
                        lock(lockobject)
                        {
                            if(dbInstance==null)
                            {
                                dbInstance = new DBFactoryInstance();
                            }
                        }
                    }
                    return dbInstance;
                }
        }
    }
}
